package com.cole.miniapp.project.config;

import com.cole.miniapp.common.service.RedisHashService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * redis管理会话配置
 * 
 * @author cole
 *
 */
@Configuration
public class RedisManageSessionConfiguration {

	private static final String SESSION_REDIS_KEY = "JPYC-X-Session-Key";
	/**
	 * 会话管理服务类，调用如下：
	 *  @Autowired
		@Qualifier("redisSessionServiceByHash")
		RedisHashService<String, String> sessionService;
	 * @param redisTemplate
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	@Bean(name = "redisSessionServiceByHash")
	public RedisHashService RedisSessionServiceByHash(@Qualifier("redisCacheTemplate") RedisTemplate redisTemplate) {
		return new RedisHashService<>(redisTemplate, SESSION_REDIS_KEY);
	}

	 
}
